with ($ns("fp.utils"))
{
    fp.utils.ContentExtractorClass = function()
    {
        var me = this;
        
        
        
        var _imgRegex = /\s*src\s*=\s*('|")?([^'">]*)/ig;
        me.extractImageUrls = function(p_html)
        {
            var result = [];
            if (p_html != null)
            {
                var matches = p_html.match(_imgRegex);
                if (matches != null)
                {
                    for (var i = 0; i < matches.length; i++)
                    {
                        var url = matches[i];
                        url = url.replace(/\s*src\s*=\s*('|")/i, "");
                        result.add(url);
                    }
                }
            }
            return result;
        };
        
        
        
        
        var _imgSingleRegex = /\s*src\s*=\s*('|")?([^'">]*)/i;
        me.extractThumbnailUrl = function(p_html)
        {
            if (p_html != null)
            {
                var matches = p_html.match(_imgSingleRegex);
                if (matches != null && matches.length == 3)
                {
                    return matches[2];
                }
            }
            return null;
        };
        
        
        
        
        
        var _thumbnailRegex = /<img[^>]*src\s*=\s*('|")?([^'">]*)\1([^>])*>/i;
        var _thumbnailWidthRegex = /\s*width\s*=\s*('|")?([^'">]*)/i;
        var _thumbnailHeightRegex = /\s*height\s*=\s*('|")?([^'">]*)/i;
        me.extractThumbnail = function(p_html)
        {
            if (p_html != null)
            {
                var matches = p_html.match(_thumbnailRegex);
                if (matches != null && matches.length == 4)
                {
                    var result = {
                        url: null,
                        width: null,
                        height: null
                    };
                    result.url = matches[2];
                    var img = matches[0];
                    matches = img.match(_thumbnailWidthRegex);
                    if (matches != null && matches.length == 3)
                    {
                        if (matches[2].indexOf("%") == -1)
                        {
                            result.width = parseInt(matches[2]);
                        }
                    }
                    matches = img.match(_thumbnailHeightRegex);
                    if (matches != null && matches.length == 3)
                    {
                        if (matches[2].indexOf("%") == -1)
                        {
                            result.height = parseInt(matches[2]);
                        }
                    }
                    return result;
                }
            }
            return null;
        };
        
        
        
        
        
        
        
        /*
        var _$content = $("<div/>");
        me.extractThumbnail = function(p_html)
        {
            var thumbnail = null;
            if (p_html != null)
            {
                _$content.html(p_html);
                var $imgs = _$content.find("img");
                for (var i = 0; i < $imgs.length; i++)
                {
                    var img = $imgs[i];
                    if (img.width == "" || img.width > 180)
                    {
                        thumbnail = {
                            url: img.src,
                            width: img.width,
                            height: img.height
                        };
                        break;
                    }
                }
                _$content.html("");
            }
            return thumbnail;
        };
        */
        
        
        
        me.extractContent = function(p_feed)
        {
            if (p_feed.content != null)
            {
                return p_feed.content.content;
            }
            else if (p_feed.summary != null)
            {
                return p_feed.summary.content;
            }
            return null;
        };
        
        return me;
    };
    
    fp.utils.ContentExtractor = new fp.utils.ContentExtractorClass(); 
}